<template>
    <div>
        用户名：<el-input v-model="loginname" />
        密码：<el-input v-model="password" />
        <el-button type="danger" @click="eventLogin">登录</el-button>
    </div>
</template>

<script>
export default {
    data() {
        return {
            loginname: '',
            password: ''
        }
    },
    methods: {
        eventLogin() {
            let url = this.$baseUrl + '/rbac/user/login'
            let data = {
                "loginName": this.loginname,
                "password": this.password
            }
            this.$http.post(url, data).then(res => {
                console.log(res)
                if (res.data.code == 200) {
                    localStorage.setItem('rbac_user',JSON.stringify( res.data.data.item3))
                    localStorage.setItem('token',res.data.data.token)
                    localStorage.setItem('reflesh_token',res.data.data.refleshToke)
                    this.$router.push('/admin/default')
                }
            })
                .catch(err => {
                    console.log(err)
                })


        }
    }
}
</script>